package com.raycloud.java.dada.service.impl;

import com.raycloud.java.dada.base.BaseService;
import com.raycloud.java.dada.base.Config;
import com.raycloud.java.dada.model.OrderCancelTest;
import com.raycloud.java.dada.model.OrderStatus;
import com.raycloud.java.dada.result.ResultModel;
import com.raycloud.java.dada.service.inter.CallbackService;
import com.raycloud.java.dada.util.BasicURL;

/**
 * Created by hechuan on 2017/6/25.
 */
public class CallbackServiceImpl extends BaseService implements CallbackService {


    public CallbackServiceImpl(Config config) {
        super(config);
    }

    /**
     * 接受订单(仅在测试环境供调试使用)
     *
     * @param orderStatus
     * @return
     */
    @Override
    public ResultModel acceptOrder(OrderStatus orderStatus)throws Exception {
        String result = doPost(orderStatus, BasicURL.ORDER_ACCEPT);
        ResultModel model = strToResultModel(result);

        return model;
    }

    /**
     * 完成取货(仅在测试环境供调试使用)
     *
     * @param orderStatus
     * @return
     */
    @Override
    public ResultModel fetchOrder(OrderStatus orderStatus)throws Exception {
        String result = doPost(orderStatus, BasicURL.ORDER_FETCH);
        ResultModel model = strToResultModel(result);

        return model;
    }

    /**
     * 完成订单(仅在测试环境供调试使用)
     *
     * @param orderStatus
     * @return
     */
    @Override
    public ResultModel finishOrder(OrderStatus orderStatus)throws Exception {
        String result = doPost(orderStatus, BasicURL.ORDER_FINISH);
        ResultModel model = strToResultModel(result);

        return model;
    }

    /**
     * 取消订单(仅在测试环境供调试使用)
     *
     * @param orderCancelTest
     * @return
     */
    @Override
    public ResultModel cancelOrder(OrderCancelTest orderCancelTest)throws Exception {
        String result = doPost(orderCancelTest, BasicURL.ORDER_CANCEL);
        ResultModel model = strToResultModel(result);

        return model;
    }

    /**
     * 订单过期(仅在测试环境供调试使用)
     *
     * @param orderStatus
     * @return
     */
    @Override
    public ResultModel expireOrder(OrderStatus orderStatus)throws Exception {
        String result = doPost(orderStatus, BasicURL.ORDER_EXPIRE);
        ResultModel model = strToResultModel(result);

        return model;
    }
}
